using UnityEngine;
namespace DefaultNamespace
{
    public class TestOverlapSphere : MonoBehaviour
    {
        [Header("检测盒子的半径")]
        public float radius;
        [Header("检测盒子的前方几米")]
        public float jimi;
    
        void Update()
        {
            //模拟的盒子中心点，x、y、z轴长度的一半
            Collider[] collider = Physics.OverlapSphere(gameObject.transform.position+transform.forward*jimi, radius,LayerMask.GetMask("Enemy"));

            foreach (var col in collider)
            {
                Debug.Log("检测到的游戏对象："+col);
            }
        }

        private void OnDrawGizmos()
        {
            Gizmos.color = Color.green;//改变线框的颜色
            Gizmos.DrawWireSphere(transform.position+transform.forward*jimi, radius);//正方体虚线框
        }
    }
}